//
//  HP_HeaderCollectionViewCell.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/8/31.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "HP_HeaderCollectionViewCell.h"

@implementation HP_HeaderCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initialize];
    }
    return self;
}

-(void)updateUIwithStatue:(BOOL)isHaveOrder{
    if (isHaveOrder == YES) {
        self.noOrder_tipLabel1.hidden = YES;
        self.noOrder_tipLabel2.hidden = YES;
        self.noOrder_tipLabel3.hidden = YES;
        self.haveOrder_timeLabel.hidden = NO;
        self.haveOrder_payBtn.hidden = NO;
        self.haveOrder_moneyLabel.hidden = NO;
        self.haveOrder_titleLabel.hidden = NO;
    }else{
        self.noOrder_tipLabel1.hidden = NO;
        self.noOrder_tipLabel2.hidden = NO;
        self.noOrder_tipLabel3.hidden = NO;
        self.haveOrder_timeLabel.hidden = YES;
        self.haveOrder_payBtn.hidden = YES;
        self.haveOrder_moneyLabel.hidden = YES;
        self.haveOrder_titleLabel.hidden = YES;
    }
}

-(void)initialize{
    
    UIView *backView = [[UIView alloc]init];
    backView.layer.masksToBounds = YES;
    backView.layer.cornerRadius = 4;
    backView.frame = CGRectMake(12, 5, ScreenWidthMao-24, 150*ScreenWidthMao/375.f-12);
    [self addSubview:backView];
    
    CAGradientLayer *caLayer = [CAGradientLayer layer];
    caLayer.frame = backView.bounds;
    caLayer.startPoint = CGPointMake(0, 0);
    caLayer.endPoint = CGPointMake(1, 1);
    //设置颜色数组
    caLayer.colors = @[(__bridge id)HexColor(0xFF9661).CGColor,
                       (__bridge id)HexColor(0xFF6D4F).CGColor];
   
    //设置颜色分割点（范围：0-1）
    caLayer.locations = @[@(0.3f), @(1.0f)];
    [backView.layer addSublayer:caLayer];
    
    _noOrder_tipLabel1 = [[UILabel alloc]init];
    _noOrder_tipLabel1.text = @"品消费 爱生活";
    _noOrder_tipLabel1.font = [UIFont systemFontOfSize:20];
    _noOrder_tipLabel1.textColor = HexColor(0xFFFFFF);
    [self addSubview:_noOrder_tipLabel1];
    [_noOrder_tipLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(backView.mas_left).offset(15);
        make.top.mas_equalTo(backView.mas_top).offset(28);
        make.height.mas_offset(@20);
    }];
    
    _noOrder_tipLabel2 = [[UILabel alloc]init];
    _noOrder_tipLabel2.text = @"爱 尚 金 服 做 有 温 度 的 金 融 服 务";
    _noOrder_tipLabel2.textColor = HexColor(0xFFFFFF);
    _noOrder_tipLabel2.font = [UIFont systemFontOfSize:12];
    [self addSubview:_noOrder_tipLabel2];
    [_noOrder_tipLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.noOrder_tipLabel1);
        make.top.mas_equalTo(self.noOrder_tipLabel1.mas_bottom).offset(5);
        make.height.mas_offset(@16);
        
    }];
    
    _noOrder_tipLabel3 = [[UILabel alloc]init];
    _noOrder_tipLabel3.text = @"极速审批|超低利率|极速到账";
    _noOrder_tipLabel3.textColor = HexColor(0xFFFFFF);
    _noOrder_tipLabel3.font = [UIFont systemFontOfSize:13];
    [self addSubview:_noOrder_tipLabel3];
    [_noOrder_tipLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.noOrder_tipLabel1);
        make.bottom.mas_equalTo(backView.mas_bottom).offset(-24);
        make.height.mas_offset(@13);
    }];
    
    _haveOrder_titleLabel = [[UILabel alloc]init];
    _haveOrder_titleLabel.textColor = HexColor(0xFFDDA7);
    _haveOrder_titleLabel.text = @"当前待还(元)";
    _haveOrder_titleLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:_haveOrder_titleLabel];
    [_haveOrder_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(backView.mas_left).offset(15);
        make.top.mas_equalTo(backView.mas_top).offset(28);
        make.height.mas_offset(@18);
    }];
    
    _haveOrder_moneyLabel = [[UILabel alloc]init];
    _haveOrder_moneyLabel.text = @"2400.00";
    _haveOrder_moneyLabel.textColor = HexColor(0xFFFFFF);
    _haveOrder_moneyLabel.font = [UIFont boldSystemFontOfSize:32];
    [self addSubview:_haveOrder_moneyLabel];
    [_haveOrder_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.haveOrder_titleLabel);
        make.top.mas_equalTo(self.haveOrder_titleLabel.mas_bottom).offset(2);
        make.height.mas_offset(34);
    }];
    
    _haveOrder_timeLabel = [[UILabel alloc]init];
    _haveOrder_timeLabel.text = @"到期日期:2018-08-15 仅剩3天";
    _haveOrder_timeLabel.font = [UIFont systemFontOfSize:13];
    _haveOrder_timeLabel.textColor = HexColor(0xFFFFFF);
    [self addSubview:_haveOrder_timeLabel];
    [_haveOrder_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.haveOrder_titleLabel);
        make.top.mas_equalTo(self.haveOrder_moneyLabel.mas_bottom).offset(12);
        make.height.mas_offset(@14);
    }];
    
    _haveOrder_payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_haveOrder_payBtn setTitle:@"立即还款" forState:UIControlStateNormal];
    [_haveOrder_payBtn setTitleColor:HexColor(0xFF7A45) forState:UIControlStateNormal];
    _haveOrder_payBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [_haveOrder_payBtn setBackgroundColor:[UIColor whiteColor]];
    _haveOrder_payBtn.layer.masksToBounds = YES;
    _haveOrder_payBtn.layer.cornerRadius = 15;
    [self addSubview:_haveOrder_payBtn];
    [_haveOrder_payBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.haveOrder_moneyLabel);
        make.right.mas_equalTo(backView.mas_right).offset(-15);
        make.width.mas_offset(@90);
        make.height.mas_offset(@30);
    }];
    
}










+(CGSize)calculateSize:(id)data{
    //    if(!data || ![data isKindOfClass:[NSArray class]]) {
    //        return CGSizeMake(0, 0);
    //    }
    return CGSizeMake(ScreenWidthMao, 150*ScreenWidthMao/375.f);
}








@end
